include_package 'processing.pdf'

def setup
  size 594, 842
  @pdf = beginRecord PDF, "RandomBook.pdf"
  beginRecord @pdf
end

def draw
  background 255
  
  100.times do |i|
    if random(1.0) < 0.2
      stroke 255
    else
      stroke 0
    end
    sw = pow random(1.0), 12
    strokeWeight sw * 260
    x1 = random -200, -100
    x2 = random width+100, width+200
    y1 = random -100, height+100
    y2 = random -100, height+100
    line x1, y1, x2, y2
  end

  if frameCount == 768
    endRecord
    exit
  else
    @pdf.nextPage
  end
end
